package com.yushealth.prostate.fingerdanceforprostate;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public class FingerActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_finger);
        // fragment
        Fragment fragment = new Finger1Fragment();
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.fragment_container, fragment);
        fragmentTransaction.commit();

        // action bar home
        ActionBar actionbar;
        if ((actionbar = getSupportActionBar()) != null) {
            actionbar.setDisplayHomeAsUpEnabled(true);
        }
    }

    private void replace(Fragment r) {
        if (getFragmentManager().findFragmentById(r.getId()) == r)
            return;
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, r);
        fragmentTransaction.commit();
    }

    public void showFinger1Click (View view) {

        replace(new Finger1Fragment());
    }

    public void showFinger2Click (View view) {
        replace(new Finger2Fragment());
    }


    // end
}
